﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Actuals.CoreDomain.Business;
using Actuals.CoreDomain;
using Actuals.CoreDomain.Data;
using Actuals.Data;

namespace Actuals.Business
{
    public class BusinessRelease : IBusinessRelease
    {

        private IDalRelease _dalReleae;

        public BusinessRelease(IDalRelease dalReleae)
        {
            _dalReleae = dalReleae;
        }

        public BusinessRelease()
        {
            _dalReleae = new DalRelease();
        }




        #region IBusinessRelease Members

        public IRelease GetRelease(int ProjectId, int ReleaseId)
        {
            return _dalReleae.GetRelease(ProjectId, ReleaseId);
        }

        public IList<IRelease> GetReleases(int projectId)
        {
            return _dalReleae.GetReleases(projectId);
        }


        #endregion

        public IList<IRelease> GetReleasesWithoutCurrentRelease(int projectId, int releaseId)
        {
            IList<IRelease> releases = GetReleases(projectId);

            IList<IRelease> releaseNoCurrentRelease = new List<IRelease>();
            foreach (IRelease release in releases)
            {
                if (release.ReleaseId != releaseId)
                {
                    releaseNoCurrentRelease.Add(release);
                }

            }
            return releaseNoCurrentRelease;
                
        }
        public bool AddRelease(IRelease release)
        {
            return _dalReleae.AddRelease(release);

        }
        public bool UpdateRelease(IRelease release)
        {
          return _dalReleae.UpdateRelease(release);
            
        }

        public bool DeleteRelease(IRelease release)
        {
            return _dalReleae.DeleteRelease(release);
        }

    }
}
